package com.ruiysoft.controller.cart;

import com.ruiysoft.pub.core.Result;
import com.ruiysoft.pub.core.ResultGenerator;
import com.ruiysoft.service.cart.ICartService;
import io.swagger.annotations.ApiParam;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.validation.Valid;
import javax.validation.constraints.NotNull;
import java.util.List;

@javax.annotation.Generated(value = "io.swagger.codegen.languages.SpringCodegen", date = "2018-11-10T13:59:36.441+08:00")

@RestController
public class InnrCartApiController implements InnrCartApi {

    private static final Logger log = LoggerFactory.getLogger(InnrCartApiController.class);

    private final ICartService cartService;


    @org.springframework.beans.factory.annotation.Autowired
    public InnrCartApiController(ICartService cartService) {
        this.cartService = cartService;
    }

    @Override
    public Result<Void> innrCartCartDelPost(@NotNull @ApiParam(value = "", required = true) @Valid @RequestParam(value = "shopId", required = true) Long shopId, @NotNull @ApiParam(value = "", required = true) @Valid @RequestParam(value = "userId", required = true) Long userId, @ApiParam(value = "" ,required=true )  @Valid @RequestBody List<Long> skuIds) {
        try {
            cartService.delSkuIds(shopId,userId,skuIds);
            return ResultGenerator.genSuccessResult();
        } catch (Exception e) {
            log.error("innr订单删除购物车商品--{}--{}--{}",shopId,userId,skuIds ,e);
            return ResultGenerator.genFailResult(e.getMessage());
        }
    }

}
